package com.guochuang.yunwang.promanager.controller;


import com.guochuang.yunwang.promanager.service.ProjectAnalysisService;
import com.guochuang.yunwang.promanager.utils.ResultEntity;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;
import java.util.Map;

@RestController
@Api(tags = "主页中项目分析接口")
public class ProjectAnalysisController {


    @Autowired
    private ProjectAnalysisService projectAnalysisService;


    @GetMapping(value = "/get/project/nums")
    @ApiOperation(value = "获取项目完结的数据")
    public ResultEntity getProjectNums(){
        Map<String, Object> rec = projectAnalysisService.getProjectNums();

        return ResultEntity.successWithData(rec);
    }

    @GetMapping(value = "/get/project/by/area")
    @ApiOperation(value = "根据区域分组聚合获取项目数据")
    public ResultEntity getProjectInfoByArea(){
        List<Map<String, Object>> rec = projectAnalysisService.getProjectInfoByArea();

        return ResultEntity.successWithData(rec);
    }


    @GetMapping(value = "/get/project/amount/by/month")
    @ApiOperation(value = "根据月份分组聚合获取项目金额数据")
    public ResultEntity getProjectAmountByMonth(){

        Map<String, Object> rec = projectAnalysisService.getProjectAmountByMonth();

        return ResultEntity.successWithData(rec);
    }

    @GetMapping(value = "/get/project/category/by/category")
    @ApiOperation(value = "根据项目类型分组聚合获取项目类型分析")
    public ResultEntity getProjectCategoryByMonth(){

        List<Map<String, Object>> rec = projectAnalysisService.getProjectCategoryInfoByCategory();

        return ResultEntity.successWithData(rec);
    }

    @GetMapping("/get/project/sortbycategory")
    @ApiOperation(value = "根据总金额倒序 项目数量正序排列项目类型")
    public ResultEntity sortbycategory(){
        return ResultEntity.successWithData(projectAnalysisService.sortbycategory());

    }

    @GetMapping("/get/project/sortbypriority")
    @ApiOperation(value = "根据项目数量倒序排列项目重要程度")
    public ResultEntity sortbypriority(){
        return ResultEntity.successWithData(projectAnalysisService.sortbypriority());

    }

}
